import { Controller, Param, Get } from "routing-controllers";
import { Helper } from '../../lib/helper';
import * as path from 'path';


@Controller('/calendar')
export class CalendarController {

    @Get("/holiday/:date")
    
    holiday(@Param("date") date: string) {
        let file = path.join(__dirname, '..', '..', 'lib/data/calendars.json');
        let calendar = Helper.readJsonFile(file);

        return (<Holiday[]>calendar).filter(m => m.Date === date);
    }
}

export interface Holiday {
    Date: string;
    HolidayName: string;
    Wage: number;
    Id: number;
}